<%--
 *  File:    OrgSummary.jsp
 *  @Author: Langerwang
 *  Date:    2001/12/10
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.EmployeeSummary");
  String strTableName = "ovemployee";
  String strModuleName = "OGM";
  String privilegeCode = "10103,L102";
%>



<%
  //get curuser info
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  String strCurOrgName = (String)CurUserInfo.get("orgname");
  Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  if(nCurOrgId == null)
  {
    nCurOrgId = new Integer(-1234567);
  }
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<%
if (request.getParameter("third")!=null)
{
    response.sendRedirect("EmployeeSummary.jsp?" + OvalTools.randomURL() + "&orgid="+CurUserInfo.get("orgid"));
    return;
}
%>


<title>EmployeeSummary</title>
<PageFlow:CheckPageFlow pageName="employeesummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);
  cat.debug("The nCurCount is :" + nCurCount);
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);

  Vector employeeSummary = (Vector)pageContext.getAttribute("emplsummary");
  if(employeeSummary == null)
  {
    employeeSummary = new Vector();
  }
  cat.debug("The employeeSummary is :" + employeeSummary);
%>
<script>
function poporg()
{
  window.open("OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=owner&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
function page_setOrg(id,name)
{
  document.employeesummaryform.orgid.value = id;
  document.employeesummaryform.orgname.value = name;
  page_summary('search');
}
function clickEmployee(id,name,orgid,deptid)
{
  document.employeesummaryform.employeeid.value = id;
  document.employeesummaryform.employeename.value = name;
  document.employeesummaryform.currentorgid.value = orgid;
  document.employeesummaryform.employeedeptid.value = deptid;
}
function page_delete()
{
	<%--[SCRIPT]  if(document.employeesummaryform.currentorgid.value!="<#%= nCurOrgId %#>")
	{
		alert("<#%= message.getMessageDesc("NO_RIGHT") %#>");
		return;
	}  [SCRIPT]--%>
  var id = document.employeesummaryform.employeeid.value;
  if(id == null || id.length == 0 || id == "" || id == "-1")
    return;
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  document.employeesummaryform.actionname.value = "delete";
  document.employeesummaryform.target = "_self";
  isRunning = true;
  document.employeesummaryform.submit();
}
function page_edit()
{
	<%--[SCRIPT]  if(document.employeesummaryform.currentorgid.value!="<#%= nCurOrgId %#>")
	{
		alert("<#%= message.getMessageDesc("NO_RIGHT") %#>");
		return;
	}  [SCRIPT]--%>
  var id = document.employeesummaryform.employeeid.value;
  if(id == null || id.length == 0 || id == "" || id == "-1")
  {
    return;
  }
  var editemployeeurl = "EmployeeEdit.jsp?<%= OvalTools.randomURL() %>&orgid=<oval:write name="orginfo" property="orgid"/>&employeeid=" + id + "&languagecode=" + "<%= strLanguageCode %>&isnew=N";
  self.location.href = editemployeeurl;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(employeesummaryform,actionvalue,orderbyname);
  editform.action = "EmployeeSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
function page_forward()
{
  self.location.href = "EmployeeEdit.jsp?<%= OvalTools.randomURL() %>&isnew=Y&orgid=" +employeesummaryform.orgid.value;
}
function page_belongto()
{
	var strUrl="DepartmentTree.jsp?<%= OvalTools.randomURL() %>&deptid=" + employeesummaryform.employeedeptid.value + "&employeeid=" + employeesummaryform.employeeid.value;
	var strPopStatus="height=400, width=200,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
	popwindow=window.open(strUrl, "newwindow", strPopStatus);
}
</script>
</head>


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <form name="employeesummaryform" method="post" action="../../Dispatcher">
      <input type="hidden" name="pagename" value="employeesummary">
      <input type="hidden" name="actionname">
			<oval:hidden name="orginfo" property="orgid"/>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0">
        <tr>
          <%if(privilegeSet != null && privilegeSet.contains("1000000")){%>
          <td nowrap><%= label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon") %>
							<%if (request.getParameter("third")==null){%>
							  <input type="text" name="orgname" value="<oval:write name="orginfo" property="orgname"/>" size="30" readonly>
							<%}else{%>
							  <oval:hidden name="userinfo" property="orgid" scope="session"/>
							  <input type="text" name="orgname" value="<oval:write name="userinfo" property="orgname" scope="session"/>" size="30" readonly>
							<%}%>
              <a onclick="poporg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a></td>
          <td>&nbsp;&nbsp;</td>
          <%}%>
          <td>
           <table>
         <%@ include file="/inc/SummarySearch.inc" %>
           </table>
          </td>
         </tr>
       </table>
    </td>
  </tr>
  <tr>
    <td>
     <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left">
          <td width="22" class="title_center">&nbsp;</td>
          <td width="80" class="title_center"><a href="javascript:page_summary('orderby','employeecode')"><%= label.getLabelName("L_EmployeeCode") %></a></td>
          <td width="80" class="title_center"><a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_EmployeeName") %></a></td>
          <td class="title_center"  width="30"><a href="javascript:page_summary('orderby','gendername')"><%= label.getLabelName("L_GenderName") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','orgname')"><%= label.getLabelName("L_OwnerOrg") %></a></td>
          <td class="title_center" width="80"><a href="javascript:page_summary('orderby','deptname')"><%= label.getLabelName("L_DefaultDeptName") %></a></td>
          <td class="title_center" width="60"><a href="javascript:page_summary('orderby','jobtitlename')"><%= label.getLabelName("L_TitleName") %></a></td>
          <td class="title_center" width="120"><a href="javascript:page_summary('orderby','email')"><%= label.getLabelName("L_Email") %></a></td>
          <td class="title_center" width="45"><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_StatusName") %></a></td>
        </tr>
          <%
            int i = 0;
            String strClassType = new String("");
            Integer nDefaultEmployeeId = new Integer(-1);
            String strDefaultEmployeeName = new String("");
            Integer nDefaultOrgId = new Integer("-1");
            Integer nDefaultDeptid = new Integer("-1");
            boolean bHasChecked = false;
          %>
          <logic:iterate id="employees" collection="<%= employeeSummary %>">
          <%
            HashMap employeeMap = (HashMap)pageContext.getAttribute("employees");
            String strIsDisabled = new String("");
            String strIsChecked = new String("");
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{
              strClassType = "none";
            }
            if(!bHasChecked)
            {
              strIsChecked = "Checked";
              bHasChecked = true;
              nDefaultEmployeeId = (Integer)(employeeMap.get("employeeid"));
              strDefaultEmployeeName = (String)(employeeMap.get("employeename"));
              nDefaultOrgId = (Integer)(employeeMap.get("orgid"));
              nDefaultDeptid = (Integer)(employeeMap.get("deptid"));
            }
            i++;
           %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue('employee<%=JspHelper.filterNull( i )%>');clickEmployee('<%=JspHelper.filterNull( employeeMap.get("employeeid") )%>','<%=JspHelper.filterNull( employeeMap.get("employeename") )%>','<%=JspHelper.filterNull( employeeMap.get("orgid") )%>','<%=JspHelper.filterNull( employeeMap.get("deptid") )%>','<%=JspHelper.filterNull( employeeMap.get("grade") )%>','<%=JspHelper.filterNull( employeeMap.get("isbottom") )%>');" class="<%=JspHelper.filterNull( strClassType )%>">
            <td height="22">
              <input id="employee<%=JspHelper.filterNull( i )%>" type="radio" name="checkemployee" value=<%=JspHelper.filterNull( employeeMap.get("employeeid") )%> class="normalradio" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickEmployee('<%=JspHelper.filterNull( employeeMap.get("employeeid") )%>','<%=JspHelper.filterNull( employeeMap.get("employeename") )%>','<%=JspHelper.filterNull( employeeMap.get("orgid") )%>','<%=JspHelper.filterNull( employeeMap.get("deptid") )%>','<%=JspHelper.filterNull( employeeMap.get("grade") )%>','<%=JspHelper.filterNull( employeeMap.get("isbottom") )%>')">
            </td>
            <td>&nbsp;<a href="EmployeeInfo.jsp?<%= OvalTools.randomURL() %>&employeeid=<%=JspHelper.filterNull( employeeMap.get("employeeid") )%>&languagecode=<%= strLanguageCode %>"><%=JspHelper.filterNull( employeeMap.get("employeecode") )%></a></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("employeename") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("gendername") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("orgname") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("deptname") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("jobtitlename") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("email") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( employeeMap.get("statusname") )%></td>
          </tr>
          </logic:iterate>
          <input type="hidden" name="employeeid" value="<%=JspHelper.filterNull( nDefaultEmployeeId )%>">
          <input type="hidden" name="employeename" value="<%=JspHelper.filterNull( strDefaultEmployeeName )%>">
          <input type="hidden" name="currentorgid" value="<%=JspHelper.filterNull( nDefaultOrgId )%>">
          <input type="hidden" name="employeedeptid" value="<%=JspHelper.filterNull( nDefaultDeptid )%>">


        <%@ include file="/inc/SummaryAction.inc" %>

      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top" ></td>
        </tr>
        <tr>
          <td class="td_center">
          	<a onclick="page_forward()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60" privilegeCode="1010310" /></a>
          	<a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60" privilegeCode="1010320"/></a>
          	<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" privilegeCode="1010330"/></a>
          	<a onclick="page_belongto()"><custom:button type="1" label="L_BelongToDept" imgsrc="delete.gif" border="0" style="width:60"/></a></td>
        </tr>
      </table>
    </td>
  </tr>
  </form>
</table>
</body>
</html>


